from flask import Flask, render_template
import sqlite3

app = Flask(__name__)

@app.route('/')
def home():
    return index()

@app.route('/index')
def index():
   return render_template('index.html')

@app.route('/about')
def about():
   return render_template('about.html')

@app.route('/movie')
def movie():
    movies = []
    con = sqlite3.connect('web_movie/movie.db')
    cur = con.cursor()
    sql = 'select * from movie250'
    data = cur.execute(sql)
    # movies = data
    for i in data:
        movies.append(i)
    con.close()
    return render_template('movie.html', movies=movies)

@app.route('/score')
def score():
    row = []
    col = []
    con = sqlite3.connect('web_movie/movie.db')
    cur = con.cursor()
    sql = 'SELECT "影片评分",COUNT(影片评分) FROM "movie250" GROUP BY "影片评分"'
    data = cur.execute(sql)
    # movies = data
    for i in data:
        row.append(i[0][1:-1])
        col.append(i[1])
    con.close()
    return render_template('score.html', rows=row, cols=col)




if __name__ == '__main__':
    app.debug = True
    app.run()

